/**
  * The introduction to the game.
  *
  * @author "Brian MacCarthy","Owen Grogan";
  * @created "2007-03-04 Brian MacCarthy";
  * @revised "$Date: 2007-03-06 19:11:00 $"; 
  */
package exfist;

import java.awt.Canvas;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Random;
import javax.imageio.ImageIO;

public class Intro extends Canvas
{
	BufferedImage intro_image1,intro_image2,intro_image3,fist;
	BufferedImage[] frames = new BufferedImage[3];
	BufferedImage[][] IntroScreen = new BufferedImage[7][2];
	SpriteCache sc=new SpriteCache();
	int intro_count;
	int startcount=0;
	int count=0;
	int flashBar=0;
	int guycount=0;
	BufferedImage bi;
	/**
	 * Splash-Screen to be displayed before game begins
	 */
	protected Intro()
	{
		bi=new BufferedImage(1024,768,1);
		intro_image1= null;

		intro_image1 = sc.getSprite("Intro_1.png");
		intro_image2 = sc.getSprite("Intro_2.png");
		intro_image3 = sc.getSprite("Intro_3.png");
		fist = sc.getSprite("Fist.gif");
		frames[0]=intro_image1;
		frames[1]=intro_image2;
		frames[2]=intro_image3;
		for(int i=0;i<7;i++)
		{
			IntroScreen[i][0]=sc.getSprite("IntroScreen"+(i+1)+".png");
			IntroScreen[i][1]=sc.getSprite("IntroScreen"+(i+1)+"-1"+".png");
		}
	}
	/**
	 * Paint Method which will be called whenever an
	 * Intro object is created.
	 */
	public BufferedImage getCurrentImage()
	{
		if(intro_count==0)
		{
			flashBar++;
			startcount++;
			guycount++;
			if(count<6)
			{
				if(startcount%15==0)count++;
			}
			if(flashBar==3)
			{
				flashBar=0;
			}
			if(guycount==9)
			{
				guycount=0;
			}
			bi.getGraphics().drawImage(frames[flashBar], 0, 0, 1024, 768, this);
			bi.getGraphics().drawImage(fist,60,50,900,650,this);
			if(startcount%5==0)
			{
				bi.getGraphics().drawImage(IntroScreen[count][0], 340, 260, 350, 250, this);
			}
			else
			{
				bi.getGraphics().drawImage(IntroScreen[count][1], 340, 260, 350, 250, this);
			}
		}
		return bi;
	}

}
